
	/***********************************************************************************************

		@NAPI
		Module: Data (native api)

		Methods:
      __ni_xml_validate	(source)
      __ni_jsn_decode   (source)
      __ni_jsn_encode   (obj)

 	************************************************************************************************/

	if(jsl.__go.JSON && jsl.__go.JSON.parse != null)
		jsl.Data.__ni_jsn_decode = function(source) {
			try {
				return JSON.parse(source + "")
			}
			catch(e) {
				jsl.throwError(e, this, arguments)
			}
		}

  if(jsl.__go.JSON && jsl.__go.JSON.stringify != null)
    jsl.Data.__ni_jsn_encode = function(obj) {
      try {
      	return JSON.stringify(obj)
      }
      catch(e) {
      	jsl.throwError(e, this, arguments)
      }
    }

	//-------------------------------------------------------------------------------
	jsl.Data.__ni_xml_validate = function(source) {
		try {
			var sid, Dom, parser, doc, dbf, db, is, e

			sid	= jsl.__sys

			//1-Standard W3C
			//-------------------------------------------------------------------------------
			if(jsl.__go.DOMParser) {

				//@sys: Opera 9.0 - LSException because too many node sibling
				parser = new jsl.__go.DOMParser

				//@sys: Explorer 11 - throws an error
			  try 			{ doc	= parser.parseFromString(source, "text/xml") 	}
				catch(e) 	{ throw jsl.ParamError("SyntaxError:source") 				}

				//!
				//1-test
				if(doc.documentElement && doc.documentElement.nodeName === "parsererror")
	    		throw jsl.ParamError("ParserError:source", doc.documentElement.childNodes[0].nodeValue)

				//2-test
				if(	doc.documentElement 																	&&
						doc.documentElement.nodeName === "html" 							&&
						doc.documentElement.childNodes[0]											&&
						doc.documentElement.childNodes[0].nodeName === "body" &&
						doc.documentElement.childNodes[0].childNodes[0] 			&&
						doc.documentElement.childNodes[0].childNodes[0].nodeName === "parsererror")
	    		throw jsl.ParamError("ParserError:source", doc.documentElement.childNodes[0].childNodes[0].nodeValue)

				//3-test
				if(	doc.documentElement 																							&&
						doc.documentElement.nodeName === "html" 													&&
						doc.documentElement.childNodes[0]																	&&
						doc.documentElement.childNodes[0].nodeName === "body" 						&&
						doc.documentElement.childNodes[0].childNodes[0] 									&&
						doc.documentElement.childNodes[0].childNodes[0].nodeName === "h1" &&
						doc.documentElement.childNodes[0].childNodes[0].childNodes[0]			&&
						doc.documentElement.childNodes[0].childNodes[0].childNodes[0].nodeValue.match(/xml\s+parsing\s+error/i))
	    		throw jsl.ParamError("ParserError:source", doc.documentElement.childNodes[0].childNodes[0].childNodes[0].nodeValue)
				//!
			}
			//2-Explorer
			//-------------------------------------------------------------------------------
			else if(jsl.__go.ActiveXObject) {

				doc 									= new jsl.__go.ActiveXObject("Microsoft.XMLDOM")
			  doc.async 						= false
				doc.validateOnParse		= false //@sys: Explorer - validate the document with the DTD
				doc.resolveExternals	= false //not supported by all platforms
			  doc.loadXML(source)

				//!
				if(doc.parseError && doc.parseError.errorCode != 0) {
					e = jsl.ParamError("ParserError:source")
					throw e.cause(doc.parseError.reason)
				}//!

				//@sys: Explorer 7 	- Obscure error: if(node.documentElement.selectNodes) throw an error
				//										because it is an ActiveXObject
				//@sys: Explorer 		- inserts the xml declaration as node in the dom also if it is not
				//										technically a processing-instruction but an xml declaration
			}
			//3-Not Supported
			//-------------------------------------------------------------------------------
			else throw jsl.NativeError("NotSupported:xml-validation")
		}
		catch(e) {
			jsl.throwError(e, this, arguments)
		}
	}
